(function () {
  const oInputWrapper = document.querySelector('.input-wrapper');

  function toggleInput(e) {
    const type = e.type,
      tar = e.target,
      oParent = tar.parentNode;

    switch (type) {
      case 'focus':
        handleFocus(tar, oParent);
        break;
      case 'blur':
        handleBlur(tar, oParent);
        break;
      default:
        break;
    }
  }

  function handleFocus(tar, parent) {
    parent.classList.add('focus');
  }

  function handleBlur(tar, parent) {
    if (tar.value === '') {
      parent.classList.remove('focus');
    }
  }

  function bindEvent() {
    oInputWrapper.addEventListener('focus', toggleInput, true);
    oInputWrapper.addEventListener('blur', toggleInput, true);
  }

  const init = () => {
    bindEvent();
  };

  init();
})();
